<template>
  <div class="recommend">
    <!-- 最近浏览 -->
    <div class="top">
      <div class="top-s">
        <div class="top-s-l">最近浏览</div>
        <div class="top-s-r">管理</div>
      </div>
      <div class="top-main">
        <ul>
          <li v-for="item in content" :key="item">
            <img src="../../../assets/img/10.png" alt="" class="li-img" />
            <img :src="item.url" alt="" class="li-img-2" />
            <p>{{ item.title }}</p>
          </li>
        </ul>
      </div>
    </div>
    <!-- 整体的一个 -->
    <div class="box-b">
      <div class="zt" v-for="(item, index) in list" :key="item">
        <!-- 评论-关注 -->
        <div class="header-i">
          <span class="span"><img :src="item.url" alt="" /></span>
          <!--zhen  -->
          <div class="header-right">
            <div class="mine">{{ item.title }}</div>
            <div class="xia">
              <div class="tian">{{ item.time }}</div>
              <div class="dian">·</div>
              <div class="youxi">{{ item.samlltitle }}</div>
            </div>
          </div>
          <!-- jia -->
          <!-- <div class="header-right">
          <div class="mine">{{ item.title }}</div>
          <div class="tian">{{ item.time }}</div>
          <div class="youxi">{{ item.samlltitle }}</div>
          <div class="dian">·</div>
        </div> -->
          <!-- jia -->
          <div class="btn">
            <!-- <img src="../../../assets/img/9.png" alt="" class="btn-img" /> -->
            <span class="btn-img" @click="tofollow(index)">{{
              state.title[index]
            }}</span>
          </div>
        </div>
        <div class="blank">
          <div class="main-content" v-if="item.wenzhang">
            {{ item.wenzhang }}
          </div>
          <img :src="item.img" alt="" class="img-1" v-if="item.img" />
        </div>
        <div class="main">
          <div class="footer">
            <div class="footer-div">
              <img src="../../../assets/img/3.png" alt="" class="img-2" />
              <span>{{ item.transpond }}</span>
            </div>
            <div class="footer-div">
              <img src="../../../assets/img/1.png" alt="" class="img-2" />
              <span>{{ item.comment }}</span>
            </div>
            <div class="footer-div">
              <img src="../../../assets/img/2.png" alt="" class="img-2" />
              <span>{{ item.like }}</span>
            </div>
            <div class="footer-div-1">
              <img src="../../../assets/img/4.png" alt="" class="img-3" />
            </div>
          </div>
        </div>
      </div>
    </div>

    <!-- 添加假的的 -->

    <!-- 假的结束 -->
    <!-- 右下角 -->
    <div class="fot">
      <img src="../../../assets/img/8.png" alt="" class="fot-img" />
    </div>
  </div>
</template>
<script>
// 用于优化滚动事件和下拉加载刷新
// 数据接口
import { getRecommendApi, getAttentionApi } from "../../../utils/app";
import { ref, reactive } from "vue";
export default {
  setup() {
    const state = reactive({
      title: [
        "关注",
        "关注",
        "关注",
        "关注",
        "关注",
        "关注",
        "关注",
        "关注",
        "关注",
      ],
    });
    const flag = ref(true);
    const tofollow = (i) => {
      if (flag.value) {
        state.title[i] = "已关注";
        flag.value = false;
      } else {
        state.title[i] = "关注";
        flag.value = true;
      }
    };
    return {
      tofollow,
      state,
      flag,
    };
  },
  data() {
    return {
      content: [],
      list: [],
    };
  },

  mounted() {
    this.getRecommendApiasync();
    this.getAttention1Apiasync();
  },
  methods: {
    // 左右的动图数据
    async getRecommendApiasync() {
      const res = await getRecommendApi();

      if (res.data.status === 0) {
        this.content = res.data.list;
      }
    },
    // 上下的评论
    async getAttention1Apiasync() {
      const res = await getAttentionApi();
      if (res.data.status === 0) {
        this.list = res.data.result;
      }
    },
  },
};
</script>

<style lang="less">
.recommend {
  background: white;

  .box-b {
    position: relative;
    // 循环的zt
    .zt {
      height: 267px;
      .blank {
        height: 150px;
      }
    }
    .tpwz {
      position: absolute;
      top: 67px;
      left: 0;
    }
  }

  // 图片 文章
  .main-content {
    padding: 2px 15px;
    overflow: hidden;
    font-size: 16px;
    font-weight: 700;
    line-height: 35px;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 4;
  }
  .img-1 {
    margin-left: 15px;
    display: block;
    width: 224px;
    height: 112px;
  }
  // 结束
  .top {
    height: 128px;
    // border: 1px solid black;
    border-bottom: 1px solid #999;
    .top-s {
      box-sizing: border-box;
      padding-left: 15px;
      width: 100%;
      height: 30px;
      display: flex;
      margin-bottom: 5px;
      // justify-content: space-between;
      .top-s-l {
        font-size: 17px;
        font-weight: bold;
        color: #333333;
        line-height: 30px;
      }
      .top-s-r {
        text-indent: 240px;
        font-size: 14px;
        font-weight: bold;
        color: #34c3c6;
        line-height: 30px;
      }
    }
    .top-main {
      display: flex;
      overflow-x: scroll;
      margin-left: 15px;
      &::-webkit-scrollbar {
        display: none;
      }
      ul:nth-last-child(1) {
        margin-right: 15px;
      }
      ul {
        // width: 100%;
        height: 85px;
        // overflow: hidden;
        display: inline-flex;
        // overflow: auto;

        li {
          // float: left;
          flex-shrink: 0;
          position: relative;
          // border: #333333 1px solid;
          margin-right: 20px;
          .li-img {
            position: absolute;
            top: 0;
            right: 0;
            display: block;
            width: 12px;
            height: 12px;
          }
          .li-img-2 {
            display: block;
            width: 50px;
            height: 50px;
            margin-bottom: 5px;
          }
          p {
            margin: 0;
            width: 50px;
            font-size: 10px;
            font-weight: 500;
            color: #333333;
            text-align: center;
            height: 30px;
            overflow: hidden;
          }
        }
      }
    }
  }
  // 1111评论-关注ii
  .header-i {
    display: flex;
    width: 100%;
    // height: 90px;
    // border: 1px solid black;
    position: relative;
    margin: 15px 0;
    .span {
      width: 34px;
      height: 34px;
      // border-radius: 50%;
      overflow: hidden;
      // border: 1px solid black;
      margin-right: 10px;
      // line-height: 90px;
      position: relative;
      top: 10px;
      left: 10px;
      img {
        // height: 100%;
        width: 34px;
        height: 34px;
        border-radius: 7px;
      }
    }
    display: flex;

    .header-right {
      position: relative;
      margin-left: 15px;
      .mine {
        font-size: 15px;
        font-weight: 700;
        // width: 100px;
        // height: 23px;
        position: relative;
        top: 4px;
        left: 0px;
      }
      .xia {
        display: flex;
        margin-top: 5px;
        // vertical-align: middle;
        line-height: 27px;
        .tian {
          font-size: 12px;
          color: #999;
        }
        .dian {
          width: 16px;
          text-align: center;
          height: 30px;
        }
        .youxi {
          font-size: 12px;
          color: #34c3c6;
          font-weight: 700;

          white-space: nowrap;
          overflow: hidden;
          text-overflow: ellipsis;
          width: 100px;
        }
      }
    }
    // jieshu
    // 点击的关注
    .btn {
      position: absolute;
      top: 15px;
      right: 15px;
      display: inline-block;
      width: 75px;
      height: 30px;
      line-height: 22px;
      color: #34c3c6;
      border-radius: 15px;
      background: #e6f8f8;
      box-sizing: border-box;
      text-align: center;
      .btn-img {
        font-size: 16px;
        // font-weight: 600;
      }
    }
  }

  .main {
    // border: 1px solid bisque;

    .footer {
      display: flex;
      width: 100%;
      height: 46px;

      .footer-div {
        flex: 1;
        width: 50%;
        display: flex;
        margin: auto;
        // border: 1px solid black;
        margin-left: 15px;
        span {
          font-size: 12px;
          color: #999;
        }
        .img-2 {
          display: block;
          width: 19px;
          height: 15px;
          margin-right: 5px;
        }
      }
      .footer-div-1 {
        // border: 1px solid black;
        flex: 2;
        position: relative;
        .img-3 {
          display: block;
          width: 3px;
          height: 10px;
          position: absolute;
          top: 18px;
          right: 20px;
        }
      }
    }
  }
  .fot {
    position: fixed;
    top: 530px;
    right: 7px;
    .fot-img {
      display: block;
      width: 78px;
      height: 78px;
    }
  }
}
</style>
